From: Adel Gadllah Date: Sun, 13 Mar 2011 11:52:30 +0000 (+0100) Subject: StScrollViewFade: Fix GLSL shader to work on r300 hardware X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~8692 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=43cf60f5636e7883bd5012e4c89ed5d57e28200c;p=gnome-shell.git StScrollViewFade: Fix GLSL shader to work on r300 hardware The number instructions in a shader is limited to 64 on r300 hardware, the fade shader in StScrollViewFade was ending up using 97 instructions which is way over the limit. So refactor the shader to use less instructions by precomputing as many values as possible outside of the conditionals. The resulting shader ends up using 34 instructions which is well within the hardware limits. https://bugzilla.gnome.org/show_bug.cgi?id=644589 --- diff --git a/src/st/st-scroll-view-fade.c b/src/st/st-scroll-view-fade.c index 3d6639ae9..74e430de2 100644 --- a/src/st/st-scroll-view-fade.c +++ b/src/st/st-scroll-view-fade.c @@ -49,21 +49,23 @@ static const gchar *fade_glsl_shader = " vec4 color = cogl_color_in * texture2D (tex, vec2 (cogl_tex_coord_in[0].xy));\n" " float y = height * cogl_tex_coord_in[0].y;\n" " float x = width * cogl_tex_coord_in[0].x;\n" -" float ratio = 0.0;\n" +" float ratio = 1.0;\n" " float fade_bottom_start = height - offset_bottom;\n" -" \n" -" if (offset_top != 0.0 && y < offset_top && ((rtl && x > scrollbar_width) || (!rtl && x < (width - scrollbar_width)))) {\n" -" ratio = y / offset_top;\n" -" cogl_color_out = color * ratio;\n" -" }\n" -" else if (offset_bottom != 0.0 && y > fade_bottom_start && ((rtl && x > scrollbar_width) || (!rtl && x < (width - scrollbar_width)))) {\n" -" ratio = (height - y)/(height - fade_bottom_start);\n" -" cogl_color_out = color * ratio;\n" +" float ratio_top = y / offset_top;\n" +" float ratio_bottom = (height - y)/(height - fade_bottom_start);\n" +" bool in_scroll_area = ((rtl && x > scrollbar_width) || (!rtl && x < (width - scrollbar_width)));\n" +" bool fade_top = y < offset_top && in_scroll_area;\n" +" bool fade_bottom = y > fade_bottom_start && in_scroll_area;\n" +"\n" +" if (fade_top) {\n" +" ratio = ratio_top;\n" " }\n" -" else { \n" -" cogl_color_out = color;\n" +" else if (fade_bottom) {\n" +" ratio = ratio_bottom;\n" " }\n" -"}\n"; +"\n" +" cogl_color_out = color * ratio;\n" +"}"; struct _StScrollViewFade {